<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
    <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
    <link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style>
html,body {
	margin: 0;
	padding: 0;
	font-size: 85%;
}
</style>
<script >
    
     var qieye = 0;
	 $(function(){
    $("#chax").button(); 
    $("#excel").button();
    $("#reset").button();
        
    loadTab(0);
    
    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#tabs" ).tabs({
		    select: function(event, ui) {
		    var i =ui.index;		       
		    if(i==''){
		    i="0";
		    }
		    qieye = i;
		    loadTab(i);
		    $("#myTab"+qieye).jqGrid('setGridParam',{url:'findVerifyHtxxList.action?htlx=3&index='+qieye,mtype:'post',page:1}).trigger("reloadGrid");
		   // alert("aa");
		    jQuery("#myTab1").jqGrid('hideCol',["Verify"]);
		        
            //return false;
  		  }
		
	});
	
	
 });
  

	
	 function loadTab(i){  
	// alert(i);
    $("#myTab"+i).jqGrid({      
    url:'findMfqr?index='+i,   
    datatype: 'json',
    mtype: 'post',         
   	colNames:['确认','合同号','企业合同号', '出卖人', '发货单位','收货单位','煤种','品种','价格','数量','签订日期','合同状态','hetid'],//,'合同状态'
   	colModel:[   
   	 {name:'Verify',index:'id',width:45,align:"center",sortable:false},	
   	 	
   		{name:'hetbh',index:'hetbh', width:120},		
   		{name:'hetlrbh',index:'hetlrbh', width:120},
   		{name:'chumdwmc',index:'chumdwmc', width:150},
   		{name:'fahdwmc',index:'fahdwmc', width:150 },
		{name:'shouhdwmc',index:'shouhdwmc', width:150 },
   	 	{name:'meiz',index:'meiz', width:80},  
		{name:'pinz',index:'pinz', width:100},  
		{name:'jiag',index:'jiag', width:60}, 
		{name:'shul',index:'shul', width:80},    		
   		{name:'qianysj',index:'qianysj', width:80},
   		{name:'zhuangt',index:'zhuangt', width:100},
   		{name:'hetid',index:'hetid'} 		
   			
   	],
    
    jsonReader: {
           repeatitems : false, 
           id: 'hetid'
         },
    width: 1250, 
    shrinkToFit:true,    	
   	rowNum:10,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,
   	rownumbers: true,   	 
    viewrecords: true,
    sortorder: 'desc',
	//loadonce:true,
	altRows:true,//隔行变色
    altclass:'ui-priority-secondary',//隔行变色样式

    //multiselect: true  
	caption: "买方确认"	,
		
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs'); 
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j]; 
			verify ="<a href='#' style='color:#f60' onclick='Verify("+ id +")'>确认</a>"; //这里的onclick就是调用了上面的javascript函数 Modify(id) 
			
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 
	
	
	
  });
  $("#myTab"+i).jqGrid('setGridHeight','280px');
  $("#myTab"+i).jqGrid('hideCol',["hetid"]);
  }
  
  
  
  function openwindow(url){
    var sheight = screen.height-70;
    var swidth = screen.width-10;
    var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
    var result=window.showModalDialog(url,"newwindow",winoption);
    if(result ==1){
     reloadhtxx(); 
     }
    return result;  
}
  
  function reloadhtxx(){
   window.location.href="findMfqrView";
}
  
   function Verify(id) { //单击修改链接的操作 
   //alert(id);
  if(id.id!=undefined){
  openwindow('findMfqrDetail?hetid='+id.id);
  }else{
    //var htbh = id.item(1).cells.item(12).innerHTML;
	openwindow('findMfqrDetail?hetid='+id );
  }
	
 
}
/*   // 查询
function search(){   
  var formdata = $("#form1").serialize(); 
 // alert(formdata); 
  $("#myTab"+qieye).jqGrid('setGridParam',{url:'findMfqr?'+formdata+'&index='+qieye,mtype:'post',page:1}).trigger("reloadGrid"); 
} */

// 查询
function search(){ 
  var formdata = $("#form1").serialize(); 
  $("#myTab"+qieye).jqGrid('setGridParam',{   
                          url:'<s:url value="/htgl"/>/findMfqr?'+formdata + '&index='+qieye,
						  mtype:'post',
						  page:1}).trigger("reloadGrid");  
}

function queryNum(){   
  var formdata = $("#form1").serialize(); 
  $.post("htgl/findVerifyHtxxListNum.action?htlx=3&index="+qieye+"&",formdata,function(data,textStatus)
  {
  
  var json = eval('(' + data + ')');

  var re=/(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
if (json[0].shul !="")
{
  // alert("价格范围："+json[0].jiag + "  总数量："+json[0].shul+"  总金额："+json[0].jine);
   $("#queryNum").html("价格范围："+json[0].jiag + "元/吨  总数量："+json[0].shul.toString().replace(re,"$1,")+"吨  总金额："+json[0].jine.toString().replace(re,"$1,")+"元");
 }
  });
  
}

function txt_onblur(i) {
            if (!event.srcElement.value) {
                event.srcElement.value = '0';
            }
           
            if (isNaN(temp)) {
                $("#"+i).val(0);                
            } 
        }
        
        //重置
			function resetSearch(){
			   $('#list_search  input[type=text]').val('');
			   $('#list_search select').val('-1');
			 }
        //导出excel
        function dc_excel(){ 
        var formdata = $("#form1").serialize(); 
	form1.action="htgl/findVerifyHtxxList_excel.action?index="+qieye;
	form1.method = "post";
	form1.submit();
	}
	</script>
</script>
</head>

<body>
	<div class="container"> 
		<div class="containerbox">
		<div class="search mt10" id="list_search">
		<form id="form1" method="post">
			<table class="search-table" width="90%"  cellpadding="0" cellspacing="0" border="0">
			<tr>
        	<td> 
            	合同录入编号: 
            </td>
            <td>
            	<input type="text" name="aa" class="form-textbox" style="width: 200px;"/> 
            </td>
            <td>
                煤种:
            </td>
            <td>
            	<div class="pr10 search-table-70"><div>
            	<select name="bb" class="form-textbox" style="width: 200px;">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="mz" items="${meiz}">
                   <option value="${mz.diccode}">
                   ${mz.dicname}
                   </option>
                   </c:forEach>
                 </select>
            	</div></div> 
            </td>            
            <td>
               品种 :
            </td>
            <td>
            	<div class="pr10 search-table-70"><div>
            	<select name="cc" class="form-textbox" style="width: 200px;">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="pz" items="${pinz}">
                   <option value="${pz.diccode}">
                   ${pz.dicname}
                   </option>
                   </c:forEach>
                 </select>
            	
            	</div></div>
            </td>
        </tr>
        <tr>
        <td>出卖人:</td>
        <td><input type="text" name="dd" class="form-textbox" style="width: 200px;"/></td>
        <td>发货单位:</td>
        <td><input type="text" name="ee" class="form-textbox" style="width: 200px;"/></td>
        <td>发站(局):</td>
        <td><input type="text" name="ff" class="form-textbox" style="width: 200px;"/></td>
        </tr>
        <tr>
        <td>买受人:</td>
        <td><input type="text" name="gg" class="form-textbox" style="width: 200px;"/></td>
        <td>收货单位:</td>
        <td><input type="text" name="hh" class="form-textbox" style="width: 200px;"/></td>
        <td>到站(局):</td>
        <td><input type="text" name="ii" class="form-textbox" style="width: 200px;"/></td>
        </tr>
        <tr>
        <td>价格:</td>
        <td><input type="text" name="jj" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" name="kk" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>数量:</td>
        <td><input type="text" name="ll" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" name="mm" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>签订日期:</td>
            <td>
            	<input id="datepicker" type="text" name="nn" class="form-textbox" style="width: 93px;"/> -- <input id="datepicker1" type="text" name="oo" class="form-textbox" style="width: 93px;"/>
            </td>
        </tr>
        <tr>
        <td>合同形式:</td>
        <td><div class="pr10 search-table-70"><div>
        <select name="pp" class="form-textbox" style="width: 200px;">
            <option value="-1" selected>==请选择==</option>
            <option value="3">省内</option>
            <option value="4">省外</option>
        </select>
        
        </div></div></td>
        <td>隶属行业:</td>
        <td><div class="pr10 search-table-70"><div>
            <select name="rr" class="form-textbox" style="width: 200px;">
                  <option value="-1" selected>==请选择==</option>
                   <c:forEach var="hy" items="${hangy}">
                   <option value="${hy.diccode}">
                   ${hy.dicname}
                   </option>
                   </c:forEach>
            </select>
        
        </div></div></td>
        <td>年度:</td>
        <td><div class="pr10 search-table-70"><div>
        <select name="uu" class="form-textbox" style="width: 200px;">
            <option value="-1" selected>==请选择==</option>
            <option value="2014">2014</option>
            <option value="2015">2015</option>
            <option value="2016">2016</option>
        </select>
        </div></div></td>
        </tr>
        <tr>
    <td align="left" valign="middle" colspan="6">
<table border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td align="right" class="pr10 search-table-70">&nbsp;</td>
    <td align="left"><input name="" type="button" class="form-button-query form-button" value="查询" onclick="search();"/>
    <input name="" type="button" class="form-button-reset form-button" value="重置"  onclick="resetSearch();"/></td>
  </tr>
</table></td>
  </tr>
        	
			</table>
		</form>
		</div>
        
		<div id="tabs">
			<ul>
				<li><a href="#tabs-0">待确认</a></li>
				<li><a href="#tabs-1">已确认</a></li>
				<li id="queryNum"  style="float:right; vertical-align: bottom; line-height:20px; top: 3px;"></li>
			</ul>
			<div id="tabs-0">
				<table id="myTab0" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager0" class="scroll"></div>
				<div id="message0" class="scroll"></div>
			</div>
			<div id="tabs-1">
				<table id="myTab1" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager1" class="scroll"></div>
				<div id="message1" class="scroll"></div>
			</div>

		</div>

		<div id="dialog-confirm" title="是否确认删除？"></div>
</div>
</div>
</body>
</html>
